#include "junix.h"
#include "list.h"

struct A
{
	int i;
	struct list_head all_list;
	struct list_head even_list;
};

int main(int argc, char **argv)
{
	struct A beg={
		.i=0,
		.all_list = LIST_HEAD_INIT(beg.all_list),
		.even_list = LIST_HEAD_INIT(beg.even_list)
	};

	for( int i=1;i<100;i++ )
	{
		struct A *pa=malloc(sizeof(struct A));
		pa->i=i;
		list_add(&pa->all_list, &beg.all_list);
		if( i%2 == 0)
			list_add(&pa->even_list, &beg.even_list);
	}

	struct A *ppa;
	list_for_each_entry(ppa, &beg.all_list, all_list)
	{
		printf("%d  ",ppa->i);
	}

	printf("\n\n");

	list_for_each_entry(ppa, &beg.even_list, even_list)
	{
		printf("%d  ",ppa->i);
	}

	printf("\n\n");

    exit(0);
}
